fix(studio): Fix sometimes not being able to select an option on the Code Agent#490
fix(studio): Fix sometimes not being able to select an option on the Code Agent#490htolentino-nvidia wants to merge 3 commits into
Conversation
Signed-off-by: Henrique Tolentino <htolentino@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughStudio now emits expired permission/input events, forwards them through SSE, clears matching runtime state, and updates agent submit behavior so Send and file submit are disabled until inputs are ready. ChangesClaude expiration events and input gating
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Signed-off-by: Henrique Tolentino <htolentino@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/api.ts`:
- Around line 392-406: The permission_expired and input_expired handlers in
ClaudeCodeChatRoute/api.ts currently return success even when payload.request_id
is missing or invalid, which lets malformed expiration events get dropped
silently. Update the event handling in the same switch/if chain that processes
permission_request and input_request so these branches fail closed: parse the
payload, validate request_id, and if it is absent or not a string, call
handlers.onError with a clear message instead of returning true. Keep the
existing onPermissionExpired/onInputExpired calls only for valid request_id
values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: c6775a72-6287-47f7-84ac-b523b69256f0
📒 Files selected for processing (7)
services/studio/src/nmp/studio/coding_agents.pyweb/packages/studio/src/components/agents/AgentDecisionInput/index.test.tsxweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/ClaudeCodeChatThread.tsxweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/api.test.tsweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/api.tsweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/types.tsweb/packages/studio/src/routes/agents/ClaudeCodeChatRoute/useClaudeCodeChatRuntime.ts
✅ Files skipped from review due to trivial changes (1)
- web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/types.ts
| if (event.event === 'permission_expired') { | ||
| const payload = parseJsonObject(event.data); | ||
| if (isRecord(payload) && typeof payload.request_id === 'string') { | ||
| handlers.onPermissionExpired?.(payload.request_id); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| if (event.event === 'input_expired') { | ||
| const payload = parseJsonObject(event.data); | ||
| if (isRecord(payload) && typeof payload.request_id === 'string') { | ||
| handlers.onInputExpired?.(payload.request_id); | ||
| } | ||
| return true; | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Fail closed on malformed expiration events.
If request_id is missing here, the event is silently dropped and the blocking UI never clears. Match the permission_request / input_request branches and surface onError instead of returning success.
Suggested fix
if (event.event === 'permission_expired') {
const payload = parseJsonObject(event.data);
- if (isRecord(payload) && typeof payload.request_id === 'string') {
- handlers.onPermissionExpired?.(payload.request_id);
- }
- return true;
+ if (!isRecord(payload) || typeof payload.request_id !== 'string') {
+ handlers.onError(new Error('Claude Code permission expiration was malformed'));
+ return false;
+ }
+ handlers.onPermissionExpired?.(payload.request_id);
+ return true;
}
if (event.event === 'input_expired') {
const payload = parseJsonObject(event.data);
- if (isRecord(payload) && typeof payload.request_id === 'string') {
- handlers.onInputExpired?.(payload.request_id);
- }
- return true;
+ if (!isRecord(payload) || typeof payload.request_id !== 'string') {
+ handlers.onError(new Error('Claude Code input expiration was malformed'));
+ return false;
+ }
+ handlers.onInputExpired?.(payload.request_id);
+ return true;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (event.event === 'permission_expired') { | |
| const payload = parseJsonObject(event.data); | |
| if (isRecord(payload) && typeof payload.request_id === 'string') { | |
| handlers.onPermissionExpired?.(payload.request_id); | |
| } | |
| return true; | |
| } | |
| if (event.event === 'input_expired') { | |
| const payload = parseJsonObject(event.data); | |
| if (isRecord(payload) && typeof payload.request_id === 'string') { | |
| handlers.onInputExpired?.(payload.request_id); | |
| } | |
| return true; | |
| } | |
| if (event.event === 'permission_expired') { | |
| const payload = parseJsonObject(event.data); | |
| if (!isRecord(payload) || typeof payload.request_id !== 'string') { | |
| handlers.onError(new Error('Claude Code permission expiration was malformed')); | |
| return false; | |
| } | |
| handlers.onPermissionExpired?.(payload.request_id); | |
| return true; | |
| } | |
| if (event.event === 'input_expired') { | |
| const payload = parseJsonObject(event.data); | |
| if (!isRecord(payload) || typeof payload.request_id !== 'string') { | |
| handlers.onError(new Error('Claude Code input expiration was malformed')); | |
| return false; | |
| } | |
| handlers.onInputExpired?.(payload.request_id); | |
| return true; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@web/packages/studio/src/routes/agents/ClaudeCodeChatRoute/api.ts` around
lines 392 - 406, The permission_expired and input_expired handlers in
ClaudeCodeChatRoute/api.ts currently return success even when payload.request_id
is missing or invalid, which lets malformed expiration events get dropped
silently. Update the event handling in the same switch/if chain that processes
permission_request and input_request so these branches fail closed: parse the
payload, validate request_id, and if it is absent or not a string, call
handlers.onError with a clear message instead of returning true. Keep the
existing onPermissionExpired/onInputExpired calls only for valid request_id
values.
Signed-off-by: Henrique Tolentino <htolentino@nvidia.com>
Summary by CodeRabbit